class FeedbackController < ApplicationController
  layout 'empty'
  def index    
    if !params[:SalesID].blank? && !params[:Response].blank?
      
      @feedback = Feedback.where("user_id = ? AND answer = ?", params[:SalesID], params[:Response]).first
      
      if @feedback.blank?
        fields = Hash.new
        fields[:code] = 1
        fields[:user_id] = params[:SalesID]
        fields[:answer] = params[:Response]
        @feedback = Feedback.new(fields) 
        @feedback.save  
      else
        if !params[:comment].blank?
          fields = Hash.new
          fields[:comment] = params[:comment]
          @feedback.update_attributes(fields)
          @success = "yes"
         end 
      end     
    end 
    
       
  end
end